package com.hdax.dm.service;

import com.hdax.dm.entity.scheduler.SchedulerSeatPrice;
import com.hdax.dm.feign.scheduler.SchedulerSeatPriceFeign;
import com.hdax.dm.vo.SeatPriceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SchedulerSeatPriceService {

    @Autowired
    private SchedulerSeatPriceFeign schedulerSeatPriceFeign;

    public List<SeatPriceVo> getPrice(Long schedulerId){
        List<SchedulerSeatPrice> lists = schedulerSeatPriceFeign.getPrice(schedulerId);
        List<SeatPriceVo> seatPriceVos = new ArrayList<>();
        lists.forEach(list->{
            SeatPriceVo seatPriceVo = new SeatPriceVo();
            BeanUtils.copyProperties(list,seatPriceVo);
            seatPriceVo.setIsHaveSeat(list.getSeatNum() == 0?0L:1L);
            seatPriceVos.add(seatPriceVo);
        });
        return seatPriceVos;
    }

}
